home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-25 | 12.6 KB | 508 lines | [TEXT/MPS ] |
- // IconEdit.h
- // Copyright © 1988-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UICONEDIT__
- #define __UICONEDIT__
-
- // MacApp
-
- #ifndef __UAPPLICATION__
- #include "UApplication.h"
- #endif
-
- #ifndef __UCOMMAND__
- #include "UCommand.h"
- #endif
-
- #ifndef __UFILEBASEDDOCUMENT__
- #include "UFileBasedDocument.h"
- #endif
-
- #ifndef __UVIEW__
- #include "UView.h"
- #endif
-
-
- // Constants
- const OSType kSignature = 'ICED'; // Application signature
- const OSType kFileType = 'ICON'; // File-type for document files created by this application
-
- // definitions for the custom apple event suite
- const OSType kAEIconEditClass = 'ICED'; // event class
-
- const OSType kAEInvertID = 'INVT'; // event IDs
- const OSType kAEZoomInID = 'ZmIn';
- const OSType kAEZoomOutID = 'ZmOt';
- const OSType kAEDrawPoints = 'DrPt';
-
- const AEKeyword keyPointList = 'kPtL';
- const AEKeyword keyErasePoints = 'kErs';
-
- // Forward references
- class TIconBitMap;
- class TIconEditView;
-
- extern short gSpecialDocCount; //Added by CKopala 8/24/96
-
- // Classes
- // ====================================================================================
-
- class TIconEditApplication : public TApplication
- {
- MA_DECLARE_CLASS;
-
- public:
- virtual ~TIconEditApplication();
- // Destructor
-
- virtual void IIconEditApplication();
-
- virtual TDocument* DoMakeDocument(CommandNumber itsCommandNumber, TFile* itsFile); // Override
- virtual MScriptableObject* TIconEditApplication::GetContainedObject(DescType desiredType,
- DescType selectionForm,const CAEDesc& selectionData);
-
- virtual TView* MakeViewForAlienClipboard(); // Override
- // Makes a view of type TIconEditView for the Clipboard if the public desk
- // scrap contains data of type 'ICON'. Otherwise it calls INHERITED
- // MakeViewForAlienClipboard.
- };
-
- // ====================================================================================
- //old class TIconDocument : public TDocument
-
- class TIconDocument : public TFileBasedDocument //new
- {
- MA_DECLARE_CLASS;
-
- protected:
- TIconBitMap* fIconBitMap; // The icon's bit map
- TIconEditView* fIconView; // a reference to the single view in this window
- CRGBColor fColor; // color property of the document
-
- public:
- TIconDocument();
- // Constructor
-
- void IIconDocument(TFile* itsDocument);
-
- virtual ~TIconDocument();
-
- virtual void DoInitialState(); // Override
-
- virtual void DoMakeViews(Boolean forPrinting); // Override
-
- virtual void DoMenuCommand(CommandNumber aCommandNumber);
-
- virtual void DoScriptCommand(CommandNumber aCommand,
- TAppleEvent* message,
- TAppleEvent* reply); // Override
-
- virtual void DoSetupMenus(); // Override
-
-
-
- virtual void DoNeedDiskSpace(TFile* itsDocument,
- long& dataForkBytes,
- long& rsrcForkBytes); // Override
-
- virtual void DoRead(TFile* itsDocument, Boolean forPrinting); // Override
-
- virtual void DoWrite(TFile* itsDocument, Boolean makingCopy); // Override
-
- virtual void InvertIcon();
-
- TIconEditView* GetIconView();
-
- virtual void ClearIcon();
-
- virtual void SetIcon(TIconBitMap* newIcon);
-
- virtual TIconBitMap* ReturnBitMap();
-
- virtual void RedrawViews();
-
- virtual void GetSetPropertyInfo(DescType whichProperty,
- CommandNumber& cmdNum,
- Boolean& canUndo,
- Boolean& causesChange,
- TCommandHandler*& theContext); // Override
-
- virtual void SetObjectProperty(const CAEDesc& thePropertyValue,
- DescType whichProperty); // Override
-
- virtual Boolean GetObjectProperty(CAEDesc& thePropertyValue,
- DescType whichProperty,
- const CAEDesc& desiredType);
- // Override
-
- virtual CRGBColor GetIconColor();
-
- virtual void SetIconColor(CRGBColor& newColor);
-
- };
-
-
- // ====================================================================================
-
- class TIconEditView : public TView
- {
- MA_DECLARE_CLASS;
-
- protected:
- short fMagnification; // No. of times to magnify the icon.
- TIconDocument *fIconDocument; // Reference to the view's icon document.
-
- public:
- TIconEditView();
- // Constructor
-
- virtual ~TIconEditView();
- // Destructor
-
- virtual void IIconEditView(TDocument* itsDocument,
- TView* itsSuperView,
- const VPoint& itsLocation,
- short itsMagnification);
-
- virtual void DoPostCreate(TDocument* itsDocument); // Override
-
- virtual void CalcMinFrame(VRect& minFrame); // Override
-
- virtual Boolean ContainsClipType(ResType aType); // Override
- // Called when a view of this type is installed in the Clipboard.
- // Returns true if aType is kIconClipType (i.e. 'ICON').
-
- virtual void DoKeyEvent(TToolboxEvent* info); // Override
- // Treats the backspace the same as the Clear command.
-
- virtual void DoMenuCommand(CommandNumber aCommandNumber); // Override
-
- virtual void DoMouseCommand(VPoint& theMouse,
- TToolboxEvent* event,
- CPoint hysteresis); // Override
-
- virtual void DoSetCursor(const VPoint& localPoint,
- RgnHandle cursorRegion); // Override
-
- virtual void DoSetupMenus(); // Override
-
- virtual void Draw(const VRect& area); // Override
-
- virtual void DrawBit(VPoint theBit, Boolean turnBitOn, CRGBColor& drawingColor);
-
- virtual Boolean PointToBit(const VPoint& thePoint, VPoint& iconBit);
-
- virtual short GetMagnification();
-
- virtual void SetMagnification(short magnification);
-
- virtual void WriteToDeskScrap(); // Override
- };
-
- // ====================================================================================
-
- class TDrawPointsAppleEvent : public TAppleEvent
- {
- MA_DECLARE_CLASS;
-
- public:
- TDrawPointsAppleEvent();
-
- virtual ~TDrawPointsAppleEvent();
- // Destructor
-
- void IDrawPointsAppleEvent( MScriptableObject *itsDirectObject,
- TIconBitMap *iconBitMapModel,
- const Boolean turnBitsOn);
- };
-
- // ====================================================================================
-
- class TDrawPointsCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- protected:
- TIconBitMap *fSavedBitMap;
- TIconDocument *fIconDocument; // The document affected by this command.
- Boolean fErasePoints;
- TDynamicArray *fPointList; // list of points to set or unset
-
- public:
- TDrawPointsCommand();
- // Constructor
-
- virtual void IDrawPointsCommand(TIconDocument *itsIconDocument,
- TAppleEvent *theAppleEvent);
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- virtual ~TDrawPointsCommand();
- };
-
- // ====================================================================================
-
- class TSetColorCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- protected:
- CRGBColor fOldColor;
- CRGBColor fNewColor;
-
- public:
- TSetColorCommand();
- // Constructor
-
- virtual ~TSetColorCommand();
- // Destructor
-
- virtual void ISetColorCommand( TIconDocument *itsIconDocument,
- CRGBColor& newColor);
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
- };
-
-
- // ====================================================================================
-
- class TInvertCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- protected:
- TIconDocument *fIconDocument; // The document affected by this command.
-
- public:
- TInvertCommand();
- // Constructor
-
- virtual ~TInvertCommand();
- // Destructor
-
- virtual void IInvertCommand(TIconDocument* itsIconDocument);
-
- virtual TAppleEvent * MakeAppleEvent();
-
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
- };
-
-
- // ====================================================================================
-
- class TIconDrawCommand : public TTracker
- {
- MA_DECLARE_CLASS;
-
- protected:
- TIconDocument *fIconDocument; // The document affected by this command.
- TIconEditView *fIconEditView; // The view in which this command draws.
- TIconBitMap *fIconBitMap; // The icon in which drawing takes place.
- TIconBitMap *fIconBitMapModel; // Model used to generate apple events
- TIconBitMap *fOriginalIcon; // A copy of the original icon.
- Boolean fTurnBitsOn; // Whether to draw bits black or white.
- CRGBColor fColor; // drawing color (property of fDocument)
-
- public:
- TIconDrawCommand();
- // Constructor
-
- virtual void IIconDrawCommand(TIconEditView* itsIconEditView,
- TIconDocument* itsIconDocument,
- VPoint& theMouse);
-
- virtual ~TIconDrawCommand();
-
- virtual void DoIt(); // Override
- // Sets the fIconDocument's icon bitmap to that of fIconBitMap by calling
- // the document's SetIcon method. Validates the edit view to avoid
- // flashing.
-
- virtual void RedoIt(); // Override
-
- virtual void TrackConstrain(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove);
-
- virtual void TrackFeedback(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn);
-
- virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
- VPoint& anchorPoint,
- VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove);
-
- virtual void UndoIt(); // Override
- // Sets the fIconDocument's icon bitmap to that of fOriginalIcon by calling
- // the document's SetIcon method.
-
- };
-
-
- // ====================================================================================
-
- class TIconEditCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- protected:
- TIconDocument *fIconDocument; // The document affected by this command.
- TIconEditView *fIconEditView; // The view in which this command draws.
- TIconBitMap *fSavedBitMap; // Saved state for undo/redo
-
- public:
- TIconEditCommand();
- // Constructor
-
- virtual void IIconEditCommand(CommandNumber itsCommandNumber,
- TIconEditView* itsIconEditView,
- TIconDocument* itsIconDocument);
- virtual ~TIconEditCommand();
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
- };
-
-
- // ====================================================================================
-
- class TIconPasteCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- protected:
- TIconDocument *fIconDocument; // The document affected by this command.
- TIconEditView *fIconEditView; // The view in which this command draws.
- TIconBitMap *fSavedIcon; // Temporary saved icon
-
- public:
- TIconPasteCommand();
- // Constructor
-
- virtual void IIconPasteCommand(TIconEditView* itsIconEditView,
- TIconDocument* itsIconDocument);
- virtual ~TIconPasteCommand();
-
- virtual void DoIt(); // Override
-
- virtual void UndoIt(); // Override
- };
-
-
- // ====================================================================================
-
- class TIconBitMap : public TObject
- {
- MA_DECLARE_CLASS;
-
- protected:
- Handle fDataHandle; // Handle to the icon's data.
-
- public:
- TIconBitMap();
- // Constructor
-
- virtual void IIconBitMap();
-
- virtual ~TIconBitMap();
-
- virtual void SetIconBitMap(Handle theBitMap);
-
- virtual void ReadFrom(TStream* aStream); // Override
-
- virtual void WriteTo(TStream* aStream); // Override
-
- virtual void LoadFromScrap();
-
- virtual void WriteToScrap();
-
- virtual TIconBitMap* Copy();
-
- virtual void CopyDataTo(TIconBitMap* anIcon);
-
- virtual void Clear();
-
- virtual void Invert();
-
- virtual void Draw(const CRect& area, const CRGBColor& drawingColor); //not Override!
-
- virtual Boolean GetBit(VPoint iconBit);
-
- virtual void SetBit(VPoint iconBit, Boolean turnBitOn);
-
- virtual void IconBitToByteBit(VPoint iconBit, short& byte, short& bit);
- };
- // ====================================================================================
- class TZoomOutCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TIconDocument *fIconDocument; // The document affected by this command.
- TZoomOutCommand();
- // Constructor
-
- virtual ~TZoomOutCommand();
- // Destructor
-
- virtual void IZoomOutCommand(TIconDocument* itsIconDocument); //, TAppleEvent* theAppleEvent);
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- virtual TAppleEvent* MakeAppleEvent();
-
- };
- // ====================================================================================
- class TZoomInCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TIconDocument *fIconDocument; // The document affected by this command.
- TZoomInCommand();
- // Constructor
-
- virtual ~TZoomInCommand();
- // Destructor
-
- virtual void IZoomInCommand(TIconDocument* itsIconDocument); //, TAppleEvent* theAppleEvent);
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- virtual TAppleEvent* MakeAppleEvent();
-
- };
-
- #endif
-